/**
 * Created by Administrator on 2016/11/30.
 */
 var baseUrl = "/api/";
angular.module("cmss.service", [])
    .factory('ProductService', ['$http', function ($http) {
        //产品Service
        var service = {};

        // 获取产品信息
        service.productFindDetail = function () {
            return $http({
                method: 'GET',
                url: baseUrl+"product/findDetail"
            });
        };

        // 获取产品信息
        service.productFind = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"/product/findAll",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };
        // 获取单个产品信息
        service.productGet = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"product/get",
                params:{"data":JSON.stringify(data)}
            });
        };

        // 获取产品版本测试规范状态实施表记录
        service.productTestRecordFind = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"product/testRecord/find",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };

        // 保存产品版本测试规范状态实施表记录
        service.productTestRecordSave = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"product/testRecord/save",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };
        // 删除产品版本测试规范状态实施表记录
        service.productTestRecordDelete = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"product/testRecord/delete",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };
        return service;
    }])
    .factory('DownloadService', ['$http', function ($http) {
        //下载Service
        var service = {};

        // 获取产品信息
        service.fileList = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"file/list",
                params:{'paramJson':JSON.stringify(data.paramJson),'type':data.type,'pageSize':data.pageSize,'currentPage':data.pageNumber}
            });
        };

        // 打包单个文件
        service.fileDownloadDir = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"file/downDir",
                params:{'id':data.id,'type':data.type,"version":data.version,"path":data.path}
            });
        };
        // 批量下载文件
        service.fileDownloadDirBatch = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"file/downDirBatch",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };
        // 下载文件
        service.fileDownload = function (data) {
            return $http({
                method: 'GET',
                url: baseUrl+"file/download",
                params:{'fileName':data.fileName,'version':data.version}
            });
        };

        // 上传文件
        service.fileUpload = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"file/upload",
                data:data,
                headers: {'Content-Type':undefined},
                transformRequest: angular.identity
            });
        };
        return service;
    }])
    .factory('SambaService', ['$http', function ($http) {
        var service = {};

        //获取单个samba数据
        service.sambaGet = function (data) {
            return $http({
                method: 'POST',
                url: baseUrl+"samba/get",
                data:JSON.stringify(data),
                dataType:"application/json"
            });
        };

        return service;
    }]);
